package com.dsczs.controller;

import com.dsczs.annotation.AutoWired;
import com.dsczs.annotation.Controller;
import com.dsczs.annotation.RequestMapping;
import com.dsczs.annotation.RequestParam;
import com.dsczs.service.UserService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/test")
public class TestController {

    @AutoWired
    private UserService userService;

    @RequestMapping("/doTest")
    public void test1(HttpServletRequest request, HttpServletResponse response,
                      @RequestParam("param") String param) {
        System.out.println(param);
        userService.test("ioc");
        try {
            response.getWriter().write("doTest method success! param:" + param);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/doTest2")
    public void test2(HttpServletRequest request, HttpServletResponse response) {
        try {
            response.getWriter().println("doTest2 method success!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
